package psn.qiuyiping.autocad.dxffile;

import psn.qiuyiping.autocad.dxffile.DxfLType.LTypeSection;

@Dxf0Name("LWPOLYLINE")
@SubClassName("AcDbPolyline")
public class DxfPolylineLW extends DxfEntity {
    public static class Vertex extends DefaultDxf0 {
        @DxfCode(42)
        double    buldge;
        @DxfCode(41)
        double    endWidth;
        @DxfCode(40)
        int       flag;
        double[]  pos;
        @DxfCode(50)
        double    rotation;
        @DxfCode(75)
        int       shape;
        @DxfCode(40)
        double    startWidth;
        @DxfCode(340)
        DxfHandle style;
        @DxfCode(9)
        String    text;

        public void unhandleCode(DxfProcessContext context, DxfData<Object> item) {
            if (item.getCode() == 10 || item.getCode() == 210) {
                context.pop();
                context.process(item);
            }else{
                super.unhandleCode(context, item);
            }
        }
    }

    boolean                closed;
    @DxfCode(38)
    double                 elevation;
    @DxfCode(90)
    int                    vertexCount;
    java.util.List<Vertex> vertexes;
    @DxfCode(43)
    double                 width;

    @DxfCode(70)
    public void readClosed(DxfProcessContext context, DxfData<Short> item) {
        this.closed = item.getVal() != 0;
    }

    @DxfCode(10)
    public void readSegment(DxfProcessContext context, DxfData item) {
        if (vertexes == null) {
            vertexes = new java.util.ArrayList<>();
        }
        Vertex seg = new Vertex();
        vertexes.add(seg);
        seg.pos = (double[]) item.getVal();
        context.push(seg);
    }
}
